﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using MaxLeaf.DB;
using System.Data;
using MySql.Data.MySqlClient;

namespace MaxLeaf.DAL.K2W
{

    public class t_MeasureUnitDAL : BaseDAL
    {
        public t_MeasureUnitDAL()
            : base()
        {
            strTableName = "goods_measure_unit";
            strOrgTableName = "t_MeasureUnit";

            strKeyFieldName = "measure_unit_id";
            strOrgKeyFieldName = "FMeasureUnitID";

            strFieldNames = "unit_group_id,measure_name,measure_coefficient,is_basic_unit,is_delete";
            strOrgFieldNames = "FUnitGroupID,FName,FCoefficient,FStandard,FDeleted";
        }


        public override int Update(DBAccess dbOrgK3Con, DBAccess dbDestWebReadCon, DBAccess dbDestWebWriteCon, string strKeyValue)
        {
            int intDestKey = base.Update(dbOrgK3Con, dbDestWebReadCon, dbDestWebWriteCon, strKeyValue);

            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["SCP"]))
            {
                //Web 2 SCP
                string strSQL = @"insert into SCP_mLog(logtype,keyvalue,logstatus)
                values(?logtype,?keyvalue,?logstatus)";
                dbDestWebWriteCon.ExecuteSql(strSQL, new MySqlParameter[] { 
                    new MySqlParameter("?logtype", "goods_measure_unit") 
                    ,new MySqlParameter("?keyvalue",  intDestKey.ToString()) 
                    ,new MySqlParameter("?logstatus", "1") 
                });
            }
            return intDestKey;
        }
 
    }
}